package team.nmsg.log.system;

import javax.servlet.http.HttpServletRequest;

import com.alibaba.fastjson.JSONArray;

import team.nmsg.ge.system.bean.SysBusinessLog;
import team.nmsg.ge.system.bean.SysRole;
import team.nmsg.ge.system.bean.SysUser;
import team.nmsg.ge.system.interf.IBusinessLogAddit;
import team.nmsg.log.NPSBusinessLogAdditThread;
import team.nmsg.log.SystemLogInterceptor;




public class AddSysRoleLogAddit implements IBusinessLogAddit {

	@Override
	public Object addBusinessLog(String methodName, Object[] args,
			Object returnValue, HttpServletRequest request , SysUser cUser) throws Exception{
		
		
		SysBusinessLog newLog = new SysBusinessLog();
		newLog.setOperTimeStamp(System.currentTimeMillis());
		newLog.setOperKey( SystemLogInterceptor.MODULE_ID+"" );
		newLog.setOperDesc("Add SysRole Rolename is_");
		newLog.setOperUserName(cUser.getUsername());
		
		
		JSONArray operArgs = new JSONArray();
		if( returnValue != null && returnValue instanceof SysRole ){
			SysRole uu = (SysRole)returnValue;
			operArgs.add( uu.getRoleName() );
			newLog.setOperResult("true");
		}else{
			newLog.setOperResult("false");
		}
		newLog.setOperArgs(  operArgs.toString()  );
		
		NPSBusinessLogAdditThread.getInstance().addBLog(newLog);
		
		return null;
	}
	
}
